from django.db import models


# Create your models here.
class Publisher(models.Model):
    pid = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32, unique=True)


class Book(models.Model):
    book_name = models.CharField(max_length=32)
    pub = models.ForeignKey('Publisher', on_delete=models.SET_NULL, null=True)


class Auther(models.Model):
    name = models.CharField(max_length=32)
    book = models.ManyToManyField('Book', through='Auther_Book')


class Auther_Book(models.Model):
    auther = models.ForeignKey('Auther', on_delete=models.CASCADE)
    book = models.ForeignKey('Book', on_delete=models.CASCADE)
